package dto

import (
	"time"
	"vrcm/src/vrcm/app/admin/models/subject"
	"vrcm/src/vrcm/common/dto"
	common "vrcm/src/vrcm/common/models"
)

type EventPaperGetPageReq struct {
	dto.Pagination `search:"-"`
	EventPaperOrder
}

type EventPaperOrder struct {
	Id         string `form:"idOrder"  search:"type:order;column:id;table:event_paper"`
	EventId    string `form:"event_idOrder"  search:"type:order;column:event_id;table:event_paper"`
	PaperId    string `form:"paper_idOrder"  search:"type:order;column:paper_id;table:event_paper"`
	TenantId   string `form:"tenant_idOrder"  search:"type:order;column:tenant_id;table:event_paper"`
	CreateTime string `form:"create_timeOrder"  search:"type:order;column:create_time;table:event_paper"`
	UpdateTime string `form:"update_timeOrder"  search:"type:order;column:update_time;table:event_paper"`
	CreateBy   string `form:"createByOrder"  search:"type:order;column:create_by;table:event_paper"`
	UpdateBy   string `form:"updateByOrder"  search:"type:order;column:update_by;table:event_paper"`
}

func (m *EventPaperGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type EventPaperInsertReq struct {
	Id       int    `json:"-" comment:""` //
	EventId  int    `json:"event_id" comment:"活动id" validate:"required"`
	PaperId  int    `json:"paper_id" comment:"试卷id" validate:"required"`
	TenantId string `json:"tenant_id" comment:"租户" validate:"required"`
	common.ControlBy
}
type EventPaperMultiInsertReq struct {
	Id       int    `json:"-" comment:""` //
	EventId  string `json:"event_id" comment:"活动id" validate:"required"`
	PaperIds []int  `json:"paper_ids" comment:"试卷id"`
	TenantId string `json:"tenant_id" comment:"租户" validate:"required"`
	common.ControlBy
}

func (s *EventPaperMultiInsertReq) Generate(model *[]subject.EventPaper) {
	for _, v := range s.PaperIds {
		v := v
		eventPaper := subject.EventPaper{}
		eventPaper.EventId = s.EventId
		eventPaper.PaperId = v
		eventPaper.TenantId = s.TenantId
		eventPaper.CreateTime = time.Now().Unix()
		eventPaper.UpdateTime = time.Now().Unix()
		eventPaper.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
		*model = append(*model, eventPaper)
	}

}

func (s *EventPaperInsertReq) GetId() interface{} {
	return s.Id
}

type EventPaperUpdateReq struct {
	Id       int    `uri:"id" comment:"" validate:"required"` //
	EventId  string `json:"event_id" comment:"活动id" validate:"required"`
	PaperId  int    `json:"paper_id" comment:"试卷id" validate:"required"`
	TenantId string `json:"tenant_id" comment:"租户" validate:"required"`
	common.ControlBy
}

func (s *EventPaperUpdateReq) Generate(model *subject.EventPaper) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.EventId = s.EventId
	model.PaperId = s.PaperId
	model.TenantId = s.TenantId
	model.CreateTime = time.Now().Unix()
	model.UpdateTime = time.Now().Unix()
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

func (s *EventPaperUpdateReq) GetId() interface{} {
	return s.Id
}

// EventPaperGetReq 功能获取请求参数
type EventPaperGetReq struct {
	Id        int      `uri:"id"`
	TenantId  string   `json:"tenant_id" comment:"租户" validate:"required"`
	EventIds  []string `json:"event_ids" comment:"活动id" validate:"required"`
	EventType int      `json:"event_type" comment:"活动类型 1 直播"`
}

func (s *EventPaperGetReq) GetId() interface{} {
	return s.Id
}

// EventPaperDeleteReq 功能删除请求参数
type EventPaperDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *EventPaperDeleteReq) GetId() interface{} {
	return s.Ids
}

type EventPaperEnableReq struct {
	EventId  string `json:"event_id" comment:"活动id" validate:"required"`
	PaperId  int    `json:"paper_id" comment:"试卷id" validate:"required"`
	TenantId string `json:"tenant_id" comment:"租户" validate:"required"`
	IsEnable int    `json:"is_enable" comment:"启用禁用 1是 2 否" validate:"required"`
	common.ControlBy
}
